<?php


namespace app\common\system\model;


use think\Model;

class OperateLog extends Model
{
    protected $type = [
        'origin'    => 'json',
        'changed'   => 'json'
    ];

    public static function write($userId, $orderId, $origin, $changed, $model, $type=0)
    {
        $data = [];
        $data['type'] = $type;
        $data['user_id'] = $userId;
        $data['order_id'] = $orderId;
        $data['origin'] = json_encode($origin);
        $data['changed'] = json_encode($changed);
        $data['model']  = $model;
        $data['create_time'] = time();
        self::insert($data);
    }

}